package com.gzist.elderlyserviceplatform.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzist.elderlyserviceplatform.entity.dto.ListQueryPageDTO;
import com.gzist.elderlyserviceplatform.entity.po.File;
import com.gzist.elderlyserviceplatform.mapper.FileMapper;
import com.gzist.elderlyserviceplatform.service.FileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 文件附件表 服务实现类
 */
@Service
public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements FileService {

    @Override
    public Page<File> queryPage(ListQueryPageDTO listQueryPageDTO) {
        Page<File> page = new Page<>(listQueryPageDTO.getPageNum(), listQueryPageDTO.getPageSize());
        LambdaQueryWrapper<File> wrapper = Wrappers.lambdaQuery();
        if (StrUtil.isNotBlank(listQueryPageDTO.getKeyWord())) {
            wrapper.like(File::getFileName, listQueryPageDTO.getKeyWord());
        }
        return this.page(page, wrapper);
    }
}
